import request from '@/utils/request'

// 获取租户列表
export function getTenantList(params) {
  return request({
    url: '/tenant/users',
    method: 'get',
    params
  })
}

// 删除租户
export function deleteTenant(id) {
  return request({
    url: '/tenant/' + id,
    method: 'delete'
  })
}

// 批量删除租户
export function batchDeleteTenants(ids) {
  return request({
    url: '/tenant/delete/batch',
    method: 'delete',
    data: ids
  })
}

// 更新租户
export function updateTenant(id, data) {
  return request({
    url: '/tenant/' + id,
    method: 'put',
    data
  })
}

// 新增租户
export function addTenant(data) {
  return request({
    url: '/register',
    method: 'post',
    data
  })
}

// 导出租户
export function exportTenants(ids, token) {
  let url = '/tenant/export?token=' + token
  if (ids && ids.length > 0) {
    url += '&ids=' + ids.join(',')
  }
  return url // 返回URL用于window.open
}

// 导入租户
export function getImportUrl() {
  return '/tenant/import'
}